<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="content-language" content="zh-CN" />
<title>订单信息查询</title>
<link rel="stylesheet" type="text/css"
	href="jquery-easyui-1.5.4.2/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css"
		href="jquery-easyui-1.5.4.2/themes/icon.css">
		<link rel="stylesheet" type="text/css"
			href="jquery-easyui-1.5.4.2/demo/demo.css">
			<script type="text/javascript"
				src="jquery-easyui-1.5.4.2/jquery.min.js"></script>
			<script type="text/javascript"
				src="jquery-easyui-1.5.4.2/jquery.easyui.min.js"></script>
			<script type="text/javascript"
				src="jquery-easyui-1.5.4.2/locale/easyui-lang-zh_CN.js"></script>
</head>
<body>
	<table>
		<tr>
			<td>日期:</td>
			<td>
				<input id="startDate" class="easyui-datebox" data-options="sharedCalendar:'#cc'">
			</td>
			
			
			<td>
				<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">查询</a>
			</td>
		</tr>
	</table>
	<div id="cc" class="easyui-calendar"></div>
	<table id="dg" class="easyui-datagrid" title="订单信息" style="width:100%;height:600px"
			data-options="rownumbers:true,
				singleSelect:true,
				autoRowHeight:false,
				pagination:true,
				pageSize:50">
		<thead>
			<tr>
				<th data-options="field:'orderId',width:150">订单编号</th>
				<th data-options="field:'username',width:150">账号</th>
				<th data-options="field:'status',width:100">订单状态</th>
				<th data-options="field:'createtime',width:150">订单时间</th>
				<th data-options="field:'size',width:100">尺寸</th>
				<th data-options="field:'payAliUrl',width:300,formatter:rowformater">支付链接</th>
			</tr>
		</thead>
	</table>
	<script>
	//得到当前日期
		formatterDate = function(date) {
		var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
		var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0"
			+ (date.getMonth() + 1);
			return date.getFullYear() + '-' + month + '-' + day;
		};
		
		window.onload = function () { 
			$('#startDate').datebox('setValue', formatterDate(new Date()));
		}

		function openNewWin(url)
		{
			window.open(url);
		}

		function rowformater(value, row, index) {
            //return "<a href=" + row.buyurl + ">转到地址</a>";//_top,
            return "<a href=\"#\" onclick=openNewWin('" + row.payAliUrl + "')>转到地址</a>"
        }
		function getData(){
			var rows = [];
			for(var i=1; i<=800; i++){
				rows.push({
					orderid: 'Inv No '+i,
					orderdate: $.fn.datebox.defaults.formatter(new Date()),
					itemdescription: 'Name '+i,
					addressitem: 'Note '+i
				});
			}
			alert(rows);
			return rows;
		}
		
		function pagerFilter(data){
			if (typeof data.length == 'number' && typeof data.splice == 'function'){	// is array
				data = {
					total: data.length,
					rows: data
				}
			}
			var dg = $(this);
			var opts = dg.datagrid('options');
			var pager = dg.datagrid('getPager');
			pager.pagination({
				onSelectPage:function(pageNum, pageSize){
					opts.pageNumber = pageNum;
					opts.pageSize = pageSize;
					pager.pagination('refresh',{
						pageNumber:pageNum,
						pageSize:pageSize
					});
					dg.datagrid('loadData',data);
				}
			});
			if (!data.originalRows){
				data.originalRows = (data.rows);
			}
			var start = (opts.pageNumber-1)*parseInt(opts.pageSize);
			var end = start + parseInt(opts.pageSize);
			data.rows = (data.originalRows.slice(start, end));
			return data;
		}
		
		 function myformatter(date){
            var y = date.getFullYear();
            var m = date.getMonth()+1;
            var d = date.getDate();
            return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);
        }
        
        function myparser(s){
            if (!s) return new Date();
            var ss = (s.split('-'));
            var y = parseInt(ss[0],10);
            var m = parseInt(ss[1],10);
            var d = parseInt(ss[2],10);
            if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
                return new Date(y,m-1,d);
            } else {
                return new Date();
            }
        }
		function submitForm(){
			var startDate = $('#startDate').datebox('getValue');
			if(startDate=='') {
				alert("请选择日期");
				return;
			}
			$('#dg').datagrid('loadData', { total: 0, rows: [] });
			var path = "getAllNikeOrder";  
			$.ajax({  
					url : path,  
					type : "post",  
					data : {  
						startDate : startDate
					},  
				dataType : "json",  
				success : function(datas) {  
					$('#dg').datagrid({loadFilter:pagerFilter}).datagrid('loadData',datas); 
				}  
			});  
		}
	</script>
</body>






